<template>
  <div>
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column prop="title" label="评审内容" show-overflow-tooltip>
        <template slot-scope="{ row }">
          <b v-show="row.status == 1">{{ showTitle(row) }}</b>
          <p v-show="row.status == 2">{{ showTitle(row) }}</p>
        </template>
      </el-table-column>
      <el-table-column prop="team" label="教师团队" show-overflow-tooltip>
        <template slot-scope="{ row }">
          {{ showTeam(row) }}
        </template>
      </el-table-column>
      <el-table-column prop="team" label="推送人" show-overflow-tooltip>
        <template slot-scope="{ row }">
          {{ row.pushPerson.userName }}
          <span class="color-success">({{ pushType(row) }}) </span>
        </template>
      </el-table-column>
      <el-table-column prop="team" label="状态" width="80">
        <template slot-scope="{ row }">
          <span v-show="row.status == 1">待评审</span>
          <span v-show="row.status == 2" class="color-success">已评审</span>
        </template>
      </el-table-column>
      <el-table-column prop="createTime" label="创建日期" width="180">
      </el-table-column>
      <el-table-column label="操作" width="240">
        <template slot-scope="{ row }">
          <el-button-group>
            <el-button
              type="success"
              size="mini"
              :disabled="!row.hasOwnProperty('sysCourseInfo')"
              @click="handlePreview(row.sysCourseInfo)"
              >预览</el-button
            >
            <el-button
              type="primary"
              size="mini"
              v-if="row.status == 1"
              :disabled="!row.hasOwnProperty('sysCourseInfo')"
              @click="handleReview(row, 'add')"
              >评审</el-button
            >
            <el-button
              type="primary"
              size="mini"
              v-if="row.status == 2"
              :disabled="!row.hasOwnProperty('sysCourseInfo')"
              @click="handleReview(row, 'edit')"
              >修改评审</el-button
            >
            <el-button
              type="primary"
              size="mini"
              v-if="row.status == 2"
              @click="handleReviewHistory(row)"
              >评审记录</el-button
            >
          </el-button-group>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import coursePreview from '@/mixins/coursePreview'
import Bus from '@/utils/bus.js'
export default {
  mixins: [coursePreview],
  computed: {
    showTitle() {
      return (row) => {
        return row.hasOwnProperty('sysCourseInfo')
          ? row.sysCourseInfo.title
          : '资源已移除或删除'
      }
    },
    showTeam() {
      return (row) => {
        return row.hasOwnProperty('sysCourseInfo')
          ? row.sysCourseInfo.team
          : '--'
      }
    },
    pushType() {
      return function (row) {
        return row.hasOwnProperty('expertsReview')
          ? row.expertsReview.title
          : '审核推送'
      }
    },
  },
  props: ['tableData'],
  methods: {
    handleReview(v, type) {
      Bus.$emit('showDialogReview', v, type)
    },
    handleReviewHistory(v) {
      Bus.$emit('showDialogReviewHistory', v)
    },
  },
}
</script>